package org.pentaho.cubic.client.toolbars;

import org.pentaho.cubic.client.commands.AnalysisViewCommand;
import org.pentaho.cubic.client.explorer.tab.CubicTabLayoutPanel;
import org.pentaho.cubic.client.widgets.ExtendedButton;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;

public class CubicToolBar extends Composite {

	private static CubicToolBarUiBinder uiBinder = GWT
			.create(CubicToolBarUiBinder.class);

	interface CubicToolBarUiBinder extends UiBinder<Widget, CubicToolBar> {
	}

	@UiField HorizontalPanel bar;
	@UiField Button btnNewReport;
	@UiField Button btnNewAnalysis;
	@UiField Button btnSave;
	@UiField Button btnSaveAs;
	@UiField Button btnViewWorkspace;


	public CubicToolBar() {
		initWidget(uiBinder.createAndBindUi(this));
		btnSave.setEnabled(false);
		btnSaveAs.setEnabled(false);
		
		this.setHeight("45px");
		this.addStyleName("cubic-ToolBar");
		
		//TEST
		ExtendedButton e = new ExtendedButton("Try Me", new AnalysisViewCommand());
		bar.add(e);
		
	}
	
	@UiHandler("btnNewReport")
	void onClickNewReport(ClickEvent e) {
		CubicTabLayoutPanel.getInstance().addTab("New Report", "New Adhoc Report", "/pentaho/adhoc/CubicWaqr.html");
	}

	@UiHandler("btnNewAnalysis")
	void onClickNewAnalysis(ClickEvent e) {
		//NewAnalysisCommand cmd = new NewAnalysisCommand();
		AnalysisViewCommand cmd = new AnalysisViewCommand();
		cmd.execute();
	}

	@UiHandler("btnViewWorkspace")
	void onClickViewWorkspace(ClickEvent e) {
		CubicTabLayoutPanel.getInstance().viewWorkspace();
	}
	

}
